package com.marco.gisdata.domain;

import com.marco.ipdata.domain.IPBase;

import java.lang.reflect.Field;

/**
 * GisBase.java
 * Create on 2017/5/5
 * Copyright(c) JD Inc 2017. All Rights Reserved.
 * <pre>
 * 功能说明：
 * </pre>
 */
public class GisBase {
    private Double lng;
    private Double lat;
    private String nation;
    private String province;
    private String city;
    private String district;
    private String nationId;
    private String provinceId;
    private String cityId;
    private String districtId;

    public GisBase(IPBase ipBase) {
        this.nation = ipBase.getNation();
        this.province = ipBase.getProvince();
        this.city = ipBase.getCity();
        this.district = ipBase.getDistrict();
        this.nationId = ipBase.getNationId();
        this.provinceId = ipBase.getProvinceId();
        this.cityId = ipBase.getCityId();
        this.districtId = ipBase.getDistrictId();
    }

    @Override
    public String toString() {
        //校验各个参数不为空
        try {
            Field[] fields = this.getClass().getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);
                if (field.get(this) == null) {
                    return "NULL";
                }
            }
            return String.format("%.2f|%.2f|%s|%s|%s|%s|%s|%s|%s|%s", lat, lng, nationId, provinceId, cityId, districtId,
                    nation, province, city, district);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public String getNationId() {
        return nationId;
    }

    public void setNationId(String nationId) {
        this.nationId = nationId;
    }

    public String getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(String provinceId) {
        this.provinceId = provinceId;
    }

    public String getCityId() {
        return cityId;
    }

    public void setCityId(String cityId) {
        this.cityId = cityId;
    }

    public String getDistrictId() {
        return districtId;
    }

    public void setDistrictId(String districtId) {
        this.districtId = districtId;
    }
}
